//
//  HMFiltrateView.m
//  HMFiltrate
//
//  Created by 陈辉明 on 2017/11/21.
//  Copyright © 2017年 goldwin. All rights reserved.
//

#import "HMFiltrateView.h"



@implementation HMFiltrateView

- (IBAction)sureButton:(UIButton *)sender {
    
   
    
    if (self.removeFromSuperviewBlock) {
        
      
        if (self.isUp) {
            
            
            
             self.removeFromSuperviewBlock(self.classNameTF.text, self.studentNameTF.text, self.selectStarButton.currentTitle,self.selectEndButton.currentTitle);
        }else{
            
            
             self.removeFromSuperviewBlock(self.classNameTF.text, self.studentNameTF.text,@"",@"");
        }
        
        
       
    }
    
    
    
}

-(void)removeFromSuperviewPush{
     [self removeFromSuperview];
    
}


- (IBAction)removeButton:(UIButton *)sender {
   // [self removeFromSuperview];
    
}
- (IBAction)beginButton:(UIButton *)sender {
    
    
    self.isUp = YES;
    
    JXAlertview *alert = [[JXAlertview alloc]initWithFrame:CGRectMake(10, 0, kScreenWidth - 60, 200)];
    alert.center = self.center;
    alert.delegate = self;
    [alert initwithtitle:@"开始时间" andcommitbtn:@"确定" andStr:@"0"];
    [alert addSubview:self.datePicker];
    [alert show];
    
    
    _mark = 1;
    
}

- (IBAction)endButton:(UIButton *)sender {
    
    
    self.isUp = YES;
    JXAlertview *alert = [[JXAlertview alloc]initWithFrame:CGRectMake(10, 0, kScreenWidth - 60, 200)];
    alert.center = self.center;
    alert.delegate = self;
    [alert initwithtitle:@"结束时间" andcommitbtn:@"确定" andStr:@"0"];
    [alert addSubview:self.datePicker];
    [alert show];
    
    
    _mark = 2;
    
    
}

- (CustomDayDatePicker *)datePicker {
    
    if (_datePicker == nil) {
        self.datePicker = [[CustomDayDatePicker alloc]initWithFrame:CGRectMake(0, 20, kScreenWidth - 60, 140)];
        
    }
    
    
    return _datePicker;
}


- (void)btnindex:(int)index :(int)tag{
    
    if (index == 2) {
        if (_mark == 1) {
            _selectDate = [NSString stringWithFormat:@"%d-%02d-%02d",self.datePicker.year,self.datePicker.month,self.datePicker.day];
            [self.selectStarButton setTitle:[NSString stringWithFormat:@"%@",_selectDate] forState:(UIControlStateNormal)];
        }else if (_mark == 2){
            
            _selectDate = [NSString stringWithFormat:@"%d-%02d-%02d",self.datePicker.year,self.datePicker.month,self.datePicker.day];
            [self.selectEndButton setTitle:[NSString stringWithFormat:@"%@",_selectDate] forState:(UIControlStateNormal)];
        }
    }
    
    
    
    
}





@end
